from k1面向对象2 import People

#继承
class Student(People):

    #类变量
    __sum = 0

    #实例变量
    name = ''
    age = 0

    #__前缀表示私有
    __score = 0

    def __init__(self,name,age):
        # People.__init__(self)   #调用父类的构造函数
        super(Student,self).__init__()

        #构造函数，实例化的时候自动调用
        self.name = name
        self.age = age
        self.__class__.__sum += 1
        print('第' + str(self.__class__.__sum) + '个对象创建')

    def marking(self,score):
        #用方法赋值可以约束变量合法，保证安全性
        if 0 <= score <= 100:
            self.__score = score

    def __cmp__(self, other):
        if self.age > other.age:
            return self.name + '年龄更大'
        elif self.age < other.age:
            return other.name + '年龄更大'
        else:
            return '一样大'
    # def __eq__(self, other):
    #     if self.name == other.name and self.age == other.age:
    #         return True
    #     else:
    #         return False
    def __str__(self):
        #toString函数
        return self.name + ' : ' + str(self.age)

    #类方法
    @classmethod
    def plus_sum(cls):
        return cls.__sum

    #静态方法
    @staticmethod
    def add(x,y):
        return x+y

class People():
    pass